'use strict';
const db = uniCloud.database();
exports.main = async (event, context) => {
  let {fileName} = event;
  
  let checkRes = await db.collection('module_key').where({
	  fileName
  }).get();
  
  if(checkRes.affectedDocs === 0 || checkRes.data.length <= 0){
	  // 不存在将其保存
	  let res = await db.collection('module_key').add({fileName});
	  return{
		  status:0,
		  msg:"验证成功！"
	  }
  } else {
	  return{
		  status:1,
		  msg:"文件名重复"
	  }
  }
  
  
  return {
	  status:-1,
	  msg:"稍后重试"
  }
};
